﻿@inject IDataCacheService _dataCacheService
@inject NavigationManager NavigationManager



<MTimeline Class="ms-2 me-2" Dense="_dataCacheService.IsApp||Model.Count<3">
    @foreach (var item in Model.Where(s=>s.IsPassed==true).OrderByDescending(s => s.ApplyTime))
    {
        <MTimelineItem Large>
            <IconContent>
                <MAvatar Class="pointer" @onclick="@(()=>OnClickUser(item))"  Color="white">
                    <img src="@item.UserInfor.PhotoPath" loading="lazy" alt="@item.UserInfor.Name" />
                </MAvatar>
            </IconContent>
            <OppositeContent>
                <span>@item.ApplyTime.ToString("yyyy-MM-dd HH:mm")</span>
            </OppositeContent>
            <ChildContent>
                <MDCard Class="elevation-2" OnClick="@(()=>OnClickExamine(item))">
                    <MCardText>
                        @if (Model.IndexOf(item) % 2 == 0 || (_dataCacheService.IsApp || Model.Count < 3))
                        {
                            <div class="comment-tx-div">
                                <div style=" display: flex; flex-wrap: wrap; align-items: center; ">
                                    <div class="title-medium me-2">@item.UserInfor.Name</div>
                                    <CnGalWebSite.Shared.MasaComponent.Shared.Cards.Ranks.RanksViewCard Model="item.UserInfor.Ranks" Outline ForceDisplayBadge />
                                     <div class="label-large">@item.ApplyTime.ToTimeFromNowString()</div>
                                </div>
                                <span class="me-2">@item.Operation.GetDisplayName()</span>

                            </div>
                        }
                        else
                        {
                            <div style="display: flex;flex-direction: column;">
                                <div style=" display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center;">
                                    <div class="label-large me-2">@item.ApplyTime.ToTimeFromNowString()</div>
                                    <CnGalWebSite.Shared.MasaComponent.Shared.Cards.Ranks.RanksViewCard Model="item.UserInfor.Ranks" Outline ForceDisplayBadge />

                                     <div class="title-medium">@item.UserInfor.Name</div>

                                </div>
                                <span class="me-2" style="text-align: end;">@item.Operation.GetDisplayName()</span>

                            </div>
                        }

                    </MCardText>
                </MDCard>
            </ChildContent>
        </MTimelineItem>
    }
</MTimeline>
@code {
    [Parameter]
    public List<ExaminedNormalListModel> Model { get; set; }
    [Parameter]
    public EventCallback OnNavClick { get; set; }


    public async Task OnClickUser(ExaminedNormalListModel model)
    {
        await OnNavClick.InvokeAsync();

        NavigationManager.NavigateTo("/space/index/" + model.UserInfor.Id);
    }
    public async Task OnClickExamine(ExaminedNormalListModel model)
    {
        await OnNavClick.InvokeAsync();

        NavigationManager.NavigateTo("/home/editrecord?ContrastId=" + model.Id);

    }
}
